home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17927 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  63 lines

  1. Path: news.rain.org!usenet
  2. From: "Guus Leeuw jr." <guusl@eiffel.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: main()
  5. Date: Wed, 17 Apr 1996 21:05:28 -0700
  6. Organization: Interactive Software Engineering Inc. http://www.eiffel.com/
  7. Message-ID: <3175BF88.5D42A0B6@eiffel.com>
  8. References: <3174c0dc.7652220@news.flex.com.au> <829766541snz@j-bg.demon.co.uk> <Dq1C8B.3sC@news.hawaii.edu>
  9. NNTP-Posting-Host: @outback.eiffel.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
  14. CC: Alvin Nonaka <xea0005@co.honolulu.hi.us>
  15.  
  16. Alvin Nonaka wrote:
  17.  
  18. [snip snip]
  19.  
  20. > I believe the authors intended to say:
  21. > #include <stdio.h>
  22. > #include <stdlib.h>
  23. > void main(void)
  24. > {
  25. >           printf("Hello!\n");
  26. >           exit(0);
  27. > }
  28. > 'main' can't return. Calling 'exit' is better because the call to exit
  29.  
  30. What? `main' cannot return? What about:
  31. int main()
  32. {
  33.   return 0;
  34. }
  35.  
  36. You mean that the whole world (plus the ANSI C Comittee) has been wring on
  37. this for years. That all portable code is not portable, etc.etc?
  38.  
  39. > 'cleans up' all resource allocations (which you are supposed to handle)
  40. > left pending in your code.
  41.  
  42. `exit' does this, but if there are no allocated resources, why call `exit'?
  43. Just return from main will do very good...
  44.  
  45. > The value passed to exit is 'returned' and control passes to the host
  46. > environment.
  47.  
  48. The value returned from `int main()' is returned and process control passes
  49. it to the host environment.
  50.  
  51. -- 
  52. 'l8r,
  53.     Guus
  54. ---------------------------------------------------------------------------
  55. They say I'm wild and I'm reckless.
  56.     -- Jim Steinman (from the song: Everything louder than everything else)
  57. ---------------------------------------------------------------------------
  58.